<template>

  <div class="admin-body">
    <el-row>
      <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>提现申请</el-breadcrumb-item>
      </el-breadcrumb>
    </el-row>
    <el-row style="padding: 15px">
      <el-row class="main">
        <!--顶部-->
        <!--<el-row style="padding-bottom: 10px;text-align: left">-->
          <!--<el-input placeholder="姓名或手机号" v-model="selectkey" class="input-with-select" style="width: 200px">-->
          <!--</el-input>-->
          <!--<el-button type="primary" @click="getStart()">搜索</el-button>-->
        <!--</el-row>-->
        <!--表格-->
        <el-table
          border
          align="left"
          :data="tableData"
          style="width: 100%">
          <el-table-column
            type="index"
            width="50">
          </el-table-column>
          <el-table-column
            prop="name"
            label="代理商名称">
          </el-table-column>
          <el-table-column
            prop="o_name"
            label="代理商团队名称">
          </el-table-column>
          <el-table-column
            prop="amount"
            label="提现金额">
          </el-table-column>
          <el-table-column
            label="发起提现时间">
            <template slot-scope="scope">
              {{toDate(scope.row.addtime)}}
            </template>
          </el-table-column>
          <el-table-column
            label="代理商类型">
            <template slot-scope="scope">
              {{typeTo(scope.row.type)}}
            </template>
          </el-table-column>
          <el-table-column
            label="操作">
            <template slot-scope="scope">
              <el-button @click="changeMes(scope.row.record_id,1)" size="small" type="text">通过</el-button>
              <el-button @click="changeMes(scope.row.record_id,3)" size="small" type="text">拒绝</el-button>
              <el-button @click="changeMes(scope.row.record_id,0)" size="small" type="text" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <!--分页-->
        <el-col :span="24" style="margin-top: 15px">
          <el-pagination
            style="text-align: right"
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="dataTotal">
          </el-pagination>
        </el-col>

      </el-row>
    </el-row>
  </div>
</template>

<script>
  export default {
    name: "ManagerApply",
    activated() {
      if (!this.$store.state.login.in) {
        this.$router.push({name: "login", params: {userId: 123}})
      }
      this.getStart()
    },
    data() {
      return {
        tableData: [],
        pageSize: 10,
        currentPage: 1,
        selectkey: '',
        dataTotal: 0,
        multipleSelection: [],
        formLabelWidth: '80px',
        userId:'',
      }
    },
    methods: {
      // 获取数据
      getStart() {
        let thi = this
        const por = {
          page: thi.currentPage,
          pageSize: thi.pageSize,
          key:this.selectkey,
          type:this.$store.state.login.typeApply,
        }
        thi.mySelectAll('withdrawList', por).then(function (value) {
          thi.tableData = value.data
          thi.dataTotal = value.Total
        })
      },
      typeTo(data){
        if(data==1){
          return '城市个人'
        }else if(data==2){
          return '城市组织'
        }else if(data==3){
          return '推广个人'
        }else {
          return '推广组织'
        }
      },
      //状态改变提示
      changeMes(id, state) {
        var heeh = '该'
        var caozuo = '通过'
        console.log(id)
        if (id.length > 1) {
          heeh = '这些'
        }
        if (state == 3) {
          caozuo = '拒绝'
        }else if(state==0){
          caozuo = '删除'
        }
        let thi = this
        thi.$confirm('此操作将'+caozuo + heeh+'信息', '是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        }).then(() => {
          thi.submitState(id, state)
        }).catch(() => {
          thi.$message({
            type: 'info',
            message: '已取消'
          });
        });
      },
      //状态改变
      submitState(id, state) {
        let thi = this
        const por = {
          id: id,
          state: state,
        }
        thi.mySubmit('editWithdrawState', por).then(function (code) {
          if (code == 200) {
            thi.getStart()
          }
        })
      },
      //选择展示数量
      handleSizeChange(val) {
        this.pageSize = val
        this.getStart()
      },
      //跳转页面
      handleCurrentChange(val) {
        this.currentPage = val
        this.getStart()
      },
    }
  }
</script>

<style scoped>
  .admin-body {
    width: 100%;
  }
  .main {
    background-color: white;
    min-height: 500px;
    padding: 10px;
    border: #EDEDED 1px solid;
    border-radius: 5px;
  }
</style>
